<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
        body {
            background: #f8f8f8;
        }

        .new {
            position: absolute;
            top: -0.3rem;
            left: -0.1rem;
            z-index: 999;
            width: 0.9rem;
        }
    </style>
</head>

<body>
    <div class="message-list vue">
        <div class="loading" v-if="loading"></div>
        <!-- 餐饮 -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='goods'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.add_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}} 预订人数<span style="color:#ff2600">{{item.num}}人</span>
                <div>预订时间：{{item.time}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.iphone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

        <!-- 酒店 -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='hotel'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.create_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}} 预订房间总数<span style="color:#ff2600">{{item.total_num}}</span>
                <div>预订入住时间：{{item.startDate}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.phone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

        <!-- KTV -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='KTV'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.create_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}}
                <div>预订包厢类型：{{item.room_type}}</div>
                <div>预订包厢场次时间：{{item.business_hours}}</div>
                <div>预订消费包厢日期：{{item.dateTime}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.phone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

        <!-- 养生 -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='health'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.create_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}}
                <div>预订养生类型：{{item.room_type}}</div>
                <div>预订到店时间：{{item.startDate}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.phone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

        <!-- 景点 -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='scenic'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.create_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}}
                <div>预订景点：{{item.scenic_type}}</div>
                <div>使用时间：{{item.startDate}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.phone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

        <!-- 其他 -->
        <div class="aui-card-list" v-for="(item,index) in list" v-if="cate_name=='other'">
            <img src="../image/new.png" class="new">
            <div class="aui-card-list-header">
                <h3>预订通知</h3>
                <span class="time">{{item.create_time}}</span>
            </div>
            <div class="aui-card-list-content-padded content">
                {{item.shop_name}}
                <div>预订商品：{{item.goods_name}}</div>
                <div>预订时间：{{item.times}}</div>
            </div>
            <div class="aui-card-list-footer">
                <span class="name">姓名：{{item.name}}</span>
                <span class="tel">联系：{{item.phone}}</span>
            </div>
            <div class="aui-card-list-footer">
                <div class="aui-btn" style="background:#fd5454;color:#ffffff" @click="detail(item)">预订详情</div>
                <div class="aui-btn aui-btn-outlined" style="border-color:#fd5454;color:#fd5454" @click="sendMsg(item,index)" v-if="item.is_msg_send==2">接受预订</div>
                <div v-else>已发送</div>
            </div>
        </div>

    </div>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/base64.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <script type="text/javascript">
        apiready = function() {
            var user = app.getUser();
            api.setRefreshHeaderInfo({
                loadingImg: 'widget://image/refresh.png',
                bgColor: '#f8f8f8',
                textColor: '#505050',
                textDown: '下拉刷新...',
                textUp: '松开刷新...'
            }, function(ret, err) {
                Ve.page = 1
                Ve.getList(function() {
                    Ve.list = []
                    api.refreshHeaderLoadDone();
                })
            });

            api.addEventListener({
                name: 'scrolltobottom',
                extra: {
                    threshold: 15
                }
            }, function(ret, err) {
                Ve.getList()
            });

            var Ve = new Vue({
                el: '.vue',
                data: {
                    loading: true,
                    cate_name: '',
                    page: 1,
                    list: []
                },
                methods: {
                    getList: function(callback) {
                        app.request.post('/myhome/business_message', {
                            business_id: user.business_id,
                            page: this.page,
                            signature: app.sign(user.business_id),
                            type: 'new'
                        }, {}, function(res) {
                            // console.log(JSON.stringify(res))
                            callback && callback()
                            if (res.code == 1) {
                                Ve.page++
                                    Ve.cate_name = res.cate_name
                                for (var i in res.data) {
                                    Ve.list.push(res.data[i])
                                }
                            } else {
                                app.error(res.msg);
                            }
                            app.loadingFinish(Ve)
                        })
                    },
                    detail: function(item) {
                        api.openWin({
                            name: 'message_detail',
                            url: 'message_detail.html',
                            pageParam: {
                                cate_name: this.cate_name,
                                message: item
                            }
                        });
                    },
                    sendMsg: function(item, index) {
                        app.request.post('/myhome/sendMsgSms', {
                            id: item.id,
                            cate_name: this.cate_name,
                            signature: app.sign(item.id)
                        }, {}, function(res) {
                            // console.log(JSON.stringify(res))
                            if (res.status == 0) {
                                Ve.list[index].is_msg_send = 1
                                app.error(res.message)
                            } else if (res.status == -3) {
                                app.error(res.msg)
                            } else {
                                app.error(res.msg)
                            }
                        })
                    }
                },
                created: function() {
                    this.getList()
                }
            })
        }
    </script>
</body>

</html>
